

#include <stdio.h>
#include "Nano1X2Series.h"
#include "GPIO_IIC.h"
#include "hdmi2mipi.h"

uint8_t buffer[20];


void hdmi_softrst()
{

	
	buffer[0]=00, buffer[1]=04, buffer[2]=04, buffer[3]=00; //</i2c_write>
	i2c_write(SLAVE_ADDRESS, buffer,4);
	buffer[0]=00, buffer[1]=02, buffer[2]=01, buffer[3]=0x3F; //</i2c_write>
	i2c_write(SLAVE_ADDRESS, buffer,4);
	buffer[0]=00, buffer[1]=02, buffer[2]=00, buffer[3]=00; //</i2c_write>
	i2c_write(SLAVE_ADDRESS, buffer,4);
	buffer[0]=00, buffer[1]=06, buffer[2]=0x08, buffer[3]=00; //</i2c_write>
	i2c_write(SLAVE_ADDRESS, buffer,4);

}

void hdmi_settx0timing()
{
	// <!-- DSI-TX0 Transition Timing -->
	buffer[0]=0x01, buffer[1]=0x08, buffer[2]=0x01, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 	
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x0C, buffer[2]=0x01, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 	
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x02, buffer[1]=0xA0, buffer[2]=0x01, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x02, buffer[1]=0xAC, buffer[2]=0xBD, buffer[3]=0x94, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	
	CLK_SysTickDelay(1000);
	
	buffer[0]=0x02, buffer[1]=0xA0, buffer[2]=0x03, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x18, buffer[2]=0x14, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x20, buffer[2]=0x70, buffer[3]=0x17, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write>
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x24, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x28, buffer[2]=0x01, buffer[3]=0x01, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x30, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x01, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x34, buffer[2]=0x00, buffer[3]=0x50, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x38, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x01, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x3C, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x01, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x40, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x01, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x44, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x01, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x48, buffer[2]=0x00, buffer[3]=0x10, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x4C, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x01, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x50, buffer[2]=0x60, buffer[3]=0x01, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x54, buffer[2]=0x01, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x58, buffer[2]=0xC8, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x68, buffer[2]=0x2A, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x70, buffer[2]=0xcb, buffer[3]=0x01, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x7C, buffer[2]=0x81, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x8C, buffer[2]=0x01, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x90, buffer[2]=0x27, buffer[3]=0x01, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0xA4, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0xC0, buffer[2]=0x15, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x02, buffer[1]=0x14, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x02, buffer[1]=0x1C, buffer[2]=0x80, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x02, buffer[1]=0x24, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x02, buffer[1]=0x54, buffer[2]=0x06, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x02, buffer[1]=0x58, buffer[2]=0x04, buffer[3]=0x02, buffer[4]=0x24, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x02, buffer[1]=0x5C, buffer[2]=0x08, buffer[3]=0x00, buffer[4]=0x0D, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x02, buffer[1]=0x60, buffer[2]=0x06, buffer[3]=0x00, buffer[4]=0x14, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x02, buffer[1]=0x64, buffer[2]=0x68, buffer[3]=0x42, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x02, buffer[1]=0x68, buffer[2]=0x0F, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x02, buffer[1]=0x6C, buffer[2]=0x08, buffer[3]=0x00, buffer[4]=0x0D, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x02, buffer[1]=0x70, buffer[2]=0x20, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x02, buffer[1]=0x74, buffer[2]=0x1F, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x02, buffer[1]=0x78, buffer[2]=0x05, buffer[3]=0x00, buffer[4]=0x06, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x02, buffer[1]=0x7C, buffer[2]=0x02, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);
	buffer[0]=0x01, buffer[1]=0x1C, buffer[2]=0x01, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00;  //</i2c_write> 
	i2c_write(SLAVE_ADDRESS, buffer,6);

}

void hdmi_settx1timing()
{
	//<!-- DSI-TX1 Transition Timing -->   
	buffer[0]=0x03, buffer[1]=0x08, buffer[2]=0x01, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS, buffer,6);	//</i2c_write
	buffer[0]=0x03, buffer[1]=0x0C, buffer[2]=0x01, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS, buffer,6);	//</i2c_write
	buffer[0]=0x04, buffer[1]=0xA0, buffer[2]=0x01, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS, buffer,6);	//</i2c_write
	buffer[0]=0x04, buffer[1]=0xAC, buffer[2]=0xBD, buffer[3]=0x94, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS, buffer,6);	//</i2c_write
	//sleep ms="1" />		
	CLK_SysTickDelay(1000);
	buffer[0]=0x04, buffer[1]=0xA0, buffer[2]=0x03, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x18, buffer[2]=0x14, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x20, buffer[2]=0x70, buffer[3]=0x17, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x24, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x28, buffer[2]=0x01, buffer[3]=0x01, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x30, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x01, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x34, buffer[2]=0x00, buffer[3]=0x50, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x38, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x01, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x3C, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x01, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x40, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x01, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x44, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x01, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x48, buffer[2]=0x00, buffer[3]=0x10, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x4C, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x01, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x50, buffer[2]=0x60, buffer[3]=0x01, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x54, buffer[2]=0x01, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x58, buffer[2]=0xC8, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x68, buffer[2]=0x2A, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x70, buffer[2]=0xcb, buffer[3]=0x01, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x7C, buffer[2]=0x81, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x8C, buffer[2]=0x01, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x90, buffer[2]=0x27, buffer[3]=0x01, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0xA4, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0xC0, buffer[2]=0x15, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x04, buffer[1]=0x14, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x04, buffer[1]=0x1C, buffer[2]=0x80, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x04, buffer[1]=0x24, buffer[2]=0x00, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x04, buffer[1]=0x54, buffer[2]=0x06, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x04, buffer[1]=0x58, buffer[2]=0x04, buffer[3]=0x02, buffer[4]=0x24, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x04, buffer[1]=0x5C, buffer[2]=0x08, buffer[3]=0x00, buffer[4]=0x0D, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x04, buffer[1]=0x60, buffer[2]=0x06, buffer[3]=0x00, buffer[4]=0x14, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x04, buffer[1]=0x64, buffer[2]=0x68, buffer[3]=0x42, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x04, buffer[1]=0x68, buffer[2]=0x0F, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x04, buffer[1]=0x6C, buffer[2]=0x08, buffer[3]=0x00, buffer[4]=0x0D, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x04, buffer[1]=0x70, buffer[2]=0x20, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x04, buffer[1]=0x74, buffer[2]=0x1F, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x04, buffer[1]=0x78, buffer[2]=0x05, buffer[3]=0x00, buffer[4]=0x06, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x04, buffer[1]=0x7C, buffer[2]=0x02, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>
	buffer[0]=0x03, buffer[1]=0x1C, buffer[2]=0x01, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write>

}


void hdmi_command_trans_init()
{
	
	//<!-- Command Transmission Before Video Start -->																									  
	buffer[0]=0x05,buffer[1]=0x00, buffer[2]=0x04, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write> 									  
	buffer[0]=0x01,buffer[1]=0x10, buffer[2]=0x16, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=00,i2c_write(SLAVE_ADDRESS,buffer,6);	//</i2c_write>		  
	buffer[0]=0x03,buffer[1]=0x10, buffer[2]=0x16, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=00,i2c_write(SLAVE_ADDRESS,buffer,6); //</i2c_write>		  
	//<!-- LCD Initialization -->																														  
	//<!-- Soft Reset -->																																  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x05, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x01, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	//<sleep ms="5" />	
	CLK_SysTickDelay(5000);
	//<!-- Set Pixel Format --> 																														  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x15, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x3A, buffer[3]=0x77,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	//<sleep ms="1" />
	CLK_SysTickDelay(1000);
	//<!-- Set Column Address -->																														  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x39, buffer[3]=0x80,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x05, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x2A, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x00, buffer[3]=0x04,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0xFF, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4);//</i2c_write> 									  
	//<sleep ms="1" />	
	CLK_SysTickDelay(1000);
	//<!-- Set Page Address --> 																														  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x39, buffer[3]=0x80,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x05, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x2B, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x00, buffer[3]=0x06,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x3F, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	//<sleep ms="1" />
	CLK_SysTickDelay(1000);
	//<!-- Set Tear On -->																																  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x15, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x35, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	//<sleep ms="1" />	
	CLK_SysTickDelay(1000);
	//<!-- Set Tear Scanline -->																														  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x39, buffer[3]=0x80,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x03, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x44, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x00, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	//<sleep ms="1" />	
	CLK_SysTickDelay(1000);
	//<!-- Write Display Brightness --> 																												  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x15, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x51, buffer[3]=0xFF,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	//<sleep ms="1" />
	CLK_SysTickDelay(1000);
	//<!-- Write Control Display -->																													  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x15, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x53, buffer[3]=0x24,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	//<sleep ms="1" />	
	CLK_SysTickDelay(1000);
	//<!-- Adaptive Brightness Control -->																												  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x15, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x55, buffer[3]=0x01,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	//<sleep ms="1" />	
	CLK_SysTickDelay(1000);
	//<!-- Exit Sleep -->																																  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x05, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x11, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	//<sleep ms="120" />		
	CLK_SysTickDelay(120000);
	//<!-- MCAP --> 																																	  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x23, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0xB0, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	//<sleep ms="1" />	
	CLK_SysTickDelay(1000);
	//<!-- Backlight Control 4 -->																														  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x29, buffer[3]=0x80,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x14, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0xCE, buffer[3]=0x7D,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x40, buffer[3]=0x48,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x56, buffer[3]=0x67,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x78, buffer[3]=0x88,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x98, buffer[3]=0xA7,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0xB5, buffer[3]=0xC3,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0xD1, buffer[3]=0xDE,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0xE9, buffer[3]=0xF2,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0xFA, buffer[3]=0xFF,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x04, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	//<!-- Split Control -->																															  
	buffer[0]=0x50, buffer[1]=0x00, buffer[2]=0x00, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x50, buffer[1]=0x0C, buffer[2]=0xE0, buffer[3]=0x84,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x50, buffer[1]=0x80, buffer[2]=0x00, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	//<!-- HDMI PHY --> 																																  
	buffer[0]=0x84, buffer[1]=0x10, buffer[2]=0x03,i2c_write(SLAVE_ADDRESS,buffer,3); //,</i2c_write>										  
	buffer[0]=0x84, buffer[1]=0x13, buffer[2]=0x3F,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>										  
	buffer[0]=0x84, buffer[1]=0x20, buffer[2]=0x07,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>										  
	buffer[0]=0x84, buffer[1]=0xF0, buffer[2]=0x31,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>										  
	buffer[0]=0x84, buffer[1]=0xF4, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>										  
	//<!-- HDMI Clock -->																																  
	buffer[0]=0x85, buffer[1]=0x40, buffer[2]=0xC0, buffer[3]=0x12,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x86, buffer[1]=0x30, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3);//,</i2c_write>										  
	buffer[0]=0x86, buffer[1]=0x31, buffer[2]=0x53, buffer[3]=0x07,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x86, buffer[1]=0x70, buffer[2]=0x02, i2c_write(SLAVE_ADDRESS,buffer,3);//,</i2c_write>										  
	buffer[0]=0x8A, buffer[1]=0x0C, buffer[2]=0xC0, buffer[3]=0x12,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	//<!-- HDMI Interrupt Mask, Clear -->																												  
	buffer[0]=0x85, buffer[1]=0x0B, buffer[2]=0xFF, i2c_write(SLAVE_ADDRESS,buffer,3);//,</i2c_write>										  
	buffer[0]=0x85, buffer[1]=0x1B, buffer[2]=0xFD, i2c_write(SLAVE_ADDRESS,buffer,3);//,</i2c_write>										  
	//<!-- Interrupt Control (TOP level) -->																											  
	buffer[0]=0x00, buffer[1]=0x14, buffer[2]=0xBF, buffer[3]=0x0F,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  
	buffer[0]=0x00, buffer[1]=0x16, buffer[2]=0xBF, buffer[3]=0x0D,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>									  

}

void hdmi_initedid()
{
	
	//<!-- EDID --> 																									
	buffer[0]=0x85, buffer[1]=0xE0, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x85, buffer[1]=0xE3, buffer[2]=0x00, buffer[3]=0x01,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>	
	//<!-- EDID Data -->																								
	buffer[0]=0x8C, buffer[1]=0x00, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x01, buffer[2]=0xFF,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x02, buffer[2]=0xFF,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x03, buffer[2]=0xFF,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x04, buffer[2]=0xFF,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x05, buffer[2]=0xFF,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x06, buffer[2]=0xFF,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x07, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x08, buffer[2]=0x52,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x09, buffer[2]=0x62,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x0A, buffer[2]=0x88,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x0B, buffer[2]=0x88,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x0C, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x0D, buffer[2]=0x88,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x0E, buffer[2]=0x88,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x0F, buffer[2]=0x88,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x10, buffer[2]=0x1C,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x11, buffer[2]=0x15,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x12, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x13, buffer[2]=0x03,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x14, buffer[2]=0x80,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x15, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x16, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x17, buffer[2]=0x78,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x18, buffer[2]=0x0A,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x19, buffer[2]=0x0D,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x1A, buffer[2]=0xC9,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x1B, buffer[2]=0xA0,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x1C, buffer[2]=0x57,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x1D, buffer[2]=0x47,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x1E, buffer[2]=0x98,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x1F, buffer[2]=0x27,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x20, buffer[2]=0x12,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x21, buffer[2]=0x48,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x22, buffer[2]=0x4C,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x23, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x24, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x25, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x26, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x27, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x28, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x29, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x2A, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x2B, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x2C, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x2D, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x2E, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x2F, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x30, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x31, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x32, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x33, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x34, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x35, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x36, buffer[2]=0xEC,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x37, buffer[2]=0x68,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x38, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x39, buffer[2]=0xA0,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x3A, buffer[2]=0xA0,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x3B, buffer[2]=0x40,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x3C, buffer[2]=0x2E,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x3D, buffer[2]=0x60,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x3E, buffer[2]=0x30,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x3F, buffer[2]=0x20,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x40, buffer[2]=0x36,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x41, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x42, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x43, buffer[2]=0x40,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x44, buffer[2]=0xA6,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x45, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x46, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x47, buffer[2]=0x1A,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x48, buffer[2]=0xEC,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x49, buffer[2]=0x68,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x4A, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x4B, buffer[2]=0xA0,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x4C, buffer[2]=0xA0,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x4D, buffer[2]=0x40,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x4E, buffer[2]=0x2E,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x4F, buffer[2]=0x60,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x50, buffer[2]=0x30,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x51, buffer[2]=0x20,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x52, buffer[2]=0x36,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x53, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x54, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x55, buffer[2]=0x40,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x56, buffer[2]=0xA6,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x57, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x58, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x59, buffer[2]=0x1A,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x5A, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x5B, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x5C, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x5D, buffer[2]=0xFC,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x5E, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x5F, buffer[2]=0x54,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x60, buffer[2]=0x6F,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x61, buffer[2]=0x73,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x62, buffer[2]=0x68,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x63, buffer[2]=0x69,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x64, buffer[2]=0x62,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x65, buffer[2]=0x61,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x66, buffer[2]=0x2D,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x67, buffer[2]=0x55,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x68, buffer[2]=0x48,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x69, buffer[2]=0x32,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x6A, buffer[2]=0x44,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x6B, buffer[2]=0x0A,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x6C, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x6D, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x6E, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x6F, buffer[2]=0xFD,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x70, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x71, buffer[2]=0x14,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x72, buffer[2]=0x78,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x73, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x74, buffer[2]=0xFF,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x75, buffer[2]=0x1D,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x76, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x77, buffer[2]=0x0A,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x78, buffer[2]=0x20,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x79, buffer[2]=0x20,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x7A, buffer[2]=0x20,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x7B, buffer[2]=0x20,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x7C, buffer[2]=0x20,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x7D, buffer[2]=0x20,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x7E, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x7F, buffer[2]=0x99,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x80, buffer[2]=0x02,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x81, buffer[2]=0x03,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x82, buffer[2]=0x1A,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x83, buffer[2]=0x40,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x84, buffer[2]=0x47,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x85, buffer[2]=0x4C,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x86, buffer[2]=0x4C,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x87, buffer[2]=0x4C,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x88, buffer[2]=0x4C,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x89, buffer[2]=0x4C,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x8A, buffer[2]=0x4C,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x8B, buffer[2]=0x4C,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x8C, buffer[2]=0x23,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x8D, buffer[2]=0x09,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x8E, buffer[2]=0x07,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x8F, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x90, buffer[2]=0x83,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x91, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x92, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x93, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x94, buffer[2]=0x65,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x95, buffer[2]=0x03,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x96, buffer[2]=0x0C,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x97, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x98, buffer[2]=0x10,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x99, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x9A, buffer[2]=0xEC,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x9B, buffer[2]=0x68,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x9C, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x9D, buffer[2]=0xA0,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x9E, buffer[2]=0xA0,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0x9F, buffer[2]=0x40,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xA0, buffer[2]=0x2E,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xA1, buffer[2]=0x60,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xA2, buffer[2]=0x30,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xA3, buffer[2]=0x20,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xA4, buffer[2]=0x36,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xA5, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xA6, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xA7, buffer[2]=0x40,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xA8, buffer[2]=0xA6,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xA9, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xAA, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xAB, buffer[2]=0x1A,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xAC, buffer[2]=0xEC,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xAD, buffer[2]=0x68,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xAE, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xAF, buffer[2]=0xA0,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xB0, buffer[2]=0xA0,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xB1, buffer[2]=0x40,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xB2, buffer[2]=0x2E,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xB3, buffer[2]=0x60,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xB4, buffer[2]=0x30,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xB5, buffer[2]=0x20,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xB6, buffer[2]=0x36,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xB7, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xB8, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xB9, buffer[2]=0x40,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xBA, buffer[2]=0xA6,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xBB, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xBC, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xBD, buffer[2]=0x1A,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xBE, buffer[2]=0xEC,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xBF, buffer[2]=0x68,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xC0, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xC1, buffer[2]=0xA0,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xC2, buffer[2]=0xA0,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xC3, buffer[2]=0x40,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xC4, buffer[2]=0x2E,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xC5, buffer[2]=0x60,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xC6, buffer[2]=0x30,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xC7, buffer[2]=0x20,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xC8, buffer[2]=0x36,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xC9, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xCA, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xCB, buffer[2]=0x40,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xCC, buffer[2]=0xA6,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xCD, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xCE, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xCF, buffer[2]=0x1A,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xD0, buffer[2]=0xEC,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xD1, buffer[2]=0x68,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xD2, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xD3, buffer[2]=0xA0,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xD4, buffer[2]=0xA0,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xD5, buffer[2]=0x40,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xD6, buffer[2]=0x2E,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xD7, buffer[2]=0x60,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xD8, buffer[2]=0x30,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xD9, buffer[2]=0x20,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xDA, buffer[2]=0x36,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xDB, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xDC, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xDD, buffer[2]=0x40,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xDE, buffer[2]=0xA6,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xDF, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xE0, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xE1, buffer[2]=0x1A,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xE2, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xE3, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xE4, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xE5, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xE6, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xE7, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xE8, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xE9, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xEA, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xEB, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xEC, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xED, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xEE, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xEF, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xF0, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xF1, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xF2, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xF3, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xF4, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xF5, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xF6, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xF7, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xF8, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xF9, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xFA, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xFB, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xFC, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xFD, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xFE, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					
	buffer[0]=0x8C, buffer[1]=0xFF, buffer[2]=0x6A,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					

}


void hdmi_hdcpsetting()
{

	
	//<!-- HDCP Setting --> 																														  
	//<!-- Video Color Format Setting -->																											  
	buffer[0]=0x8A, buffer[1]=0x02, buffer[2]=0x42,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>												  
	//<!-- HDMI SYSTEM -->																															  
	buffer[0]=0x85, buffer[1]=0x43, buffer[2]=0x02,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>												  
	buffer[0]=0x85, buffer[1]=0x44, buffer[2]=0x10,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>												  
	//<!-- HDMI Audio Setting -->																													  
	buffer[0]=0x86, buffer[1]=0x00, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>												  
	buffer[0]=0x86, buffer[1]=0x02, buffer[2]=0xF3,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>												  
	buffer[0]=0x86, buffer[1]=0x03, buffer[2]=0x02,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>												  
	buffer[0]=0x86, buffer[1]=0x04, buffer[2]=0x0C,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>												  
	buffer[0]=0x86, buffer[1]=0x06, buffer[2]=0x05,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>												  
	buffer[0]=0x86, buffer[1]=0x07, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>												  
	buffer[0]=0x86, buffer[1]=0x52, buffer[2]=0x02,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>												  
	buffer[0]=0x86, buffer[1]=0x71, buffer[2]=0xBA, buffer[3]=0x49, buffer[4]=0x0C, buffer[5]=0x02,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write> 
	buffer[0]=0x86, buffer[1]=0x75, buffer[2]=0x89, buffer[3]=0xB0, buffer[4]=0xE1, buffer[5]=0x01,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write> 
	buffer[0]=0x86, buffer[1]=0x80, buffer[2]=0x00,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>													  
	//<!-- Let HDMI Source start access --> 																										  
	buffer[0]=0x85, buffer[1]=0x4A, buffer[2]=0x01,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>												  

}


uint8_t hdmi_wait_hdmisync()
{
	
	//<!-- HDMI Signal Detection -->																					  
	//<!-- Wait until HDMI sync is established -->																		  
	//<!-- By Interrupt   In Interrupt Service Routine. --> 															  
	buffer[0]=0x85, buffer[1]=0x20,i2c_write(SLAVE_ADDRESS,buffer,2);	//</i2c_write>	
	i2c_read(SLAVE_ADDRESS,buffer,1);
	if(buffer[0]&0x80)
		{
			return 1;
		}
	//<i2c_read addr="0x0F" count="1" radix="16" /> 																	  
	//<!-- Sequence: Check bit7 of 8x8520 -->																			  
	buffer[0]=0x85, buffer[1]=0x0B, buffer[2]=0xFF,i2c_write(SLAVE_ADDRESS,buffer,3); //</i2c_write>					  
	buffer[0]=0x00, buffer[1]=0x14, buffer[2]=0xBF, buffer[3]=0x0F,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>	  
	//<!-- By Polling -->																								  
	buffer[0]=0x85, buffer[1]=0x20,i2c_write(SLAVE_ADDRESS,buffer,2);	//</i2c_write>		

	while(1)
		{
			i2c_read(SLAVE_ADDRESS,buffer,1);
			if(buffer[0]&0x80)
				{
					return 1;
				}
			CLK_SysTickDelay(10000);
		}

	return 0;
	//<i2c_read addr="0x0F" count="1" radix="16" /> 																	  
	//<!-- Sequence: Check bit7 of 8x8520 -->																			  
	//<!-- Start Video TX -->																							  

}



void hdmi_video_start()
{

	
	//<!-- Start Video TX -->																														  
	buffer[0]=0x00, buffer[1]=0x04, buffer[2]=0x37, buffer[3]=0x0C,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>								  
	buffer[0]=0x00, buffer[1]=0x06, buffer[2]=0x00, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>								  
	//<!-- Command Transmission After Video Start. -->																								  
	buffer[0]=0x01, buffer[1]=0x10, buffer[2]=0x06, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write> 
	buffer[0]=0x03, buffer[1]=0x10, buffer[2]=0x06, buffer[3]=0x00, buffer[4]=0x00, buffer[5]=0x00,i2c_write(SLAVE_ADDRESS,buffer,6);  //</i2c_write> 
	//<sleep ms="1000" />
	CLK_SysTickDelay(1000);
	//<!-- MCAP --> 																																  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x23, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>								  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0xB0, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>								  
	//<sleep ms="1" />	
	CLK_SysTickDelay(1000);
	//<!-- Interface Setting -->																													  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x23, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>								  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0xB3, buffer[3]=0x14,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>								  
	//<sleep ms="1" />	
	CLK_SysTickDelay(1000);
	//<!-- MCAP --> 																																  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x23, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>								  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0xB0, buffer[3]=0x03,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>								  
	//<sleep ms="1" />	
	CLK_SysTickDelay(1000);
	//<!-- Set Display On -->																														  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x05, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>								  
	buffer[0]=0x05, buffer[1]=0x04, buffer[2]=0x29, buffer[3]=0x00,i2c_write(SLAVE_ADDRESS,buffer,4); //</i2c_write>								  
	//<sleep ms="1" />	
	CLK_SysTickDelay(1000);
																																					  

}

void init_hdmi2mipi()
{
	hdmi_softrst();
	hdmi_settx0timing();
	hdmi_settx1timing();
	hdmi_command_trans_init();
	hdmi_initedid();
	hdmi_hdcpsetting();

	if(hdmi_wait_hdmisync())
		{
			hdmi_video_start();
		}
	

}



